

#import "AppServiceData.h"


@interface AppServiceData()

@property(nonatomic,strong) NSMutableArray *theHospitalList;

@end

@implementation AppServiceData


-(instancetype)init{
    
    self.theHospitalList = [[NSMutableArray alloc]init];
    
    /*
     * 开发测试库 2017-4
     */
    AppServiceModel *dev = [[AppServiceModel alloc]init];
    dev.HospitalCode = @"dev";
    dev.HospitalName = @"开发测试库";
    dev.IPAddressOrDomainName = @"10.95.4.17";
    dev.IISApplicationName = @"";
    dev.Port = @"80";
    [self.theHospitalList addObject: dev];
    
    AppServiceModel *debug = [[AppServiceModel alloc]init];
    debug.HospitalCode = @"debug";
    debug.HospitalName = @"开发调试库";
    debug.IPAddressOrDomainName = @"zjhrp.vicp.net";
    debug.IISApplicationName = @"xmxy";
    debug.Port = @"280";
    [self.theHospitalList addObject: debug];
    
    AppServiceModel *xiamen_xianyue = [[AppServiceModel alloc]init];
    xiamen_xianyue.HospitalCode = @"0592008";
    xiamen_xianyue.HospitalName = @"厦门仙岳医院";
    xiamen_xianyue.IPAddressOrDomainName = @"10.95.4.17";
    xiamen_xianyue.IISApplicationName = @"";
    xiamen_xianyue.Port = @"80";
    [self.theHospitalList addObject: xiamen_xianyue];
    
//    zjhrp.vicp.net:280/xmxy/home/main
    AppServiceModel *xiamen_fuyou = [[AppServiceModel alloc]init];
    xiamen_fuyou.HospitalCode = @"0592008";
    xiamen_fuyou.HospitalName = @"厦门妇幼医院";
    xiamen_fuyou.IPAddressOrDomainName = @"10.10.5.97";
    xiamen_fuyou.IISApplicationName = @"";
    xiamen_fuyou.Port = @"80";
    [self.theHospitalList addObject: xiamen_fuyou];
    
    
    AppServiceModel *ceshi = [[AppServiceModel alloc]init];
    xiamen_xianyue.HospitalCode = @"ceshi";
    xiamen_xianyue.HospitalName = @"测试库";
    xiamen_xianyue.IPAddressOrDomainName = @"192.168.2.135";
    xiamen_xianyue.IISApplicationName = @"";
    xiamen_xianyue.Port = @"8083";
    [self.theHospitalList addObject: ceshi];
    
    
    AppServiceModel *guangxi_beiliu = [[AppServiceModel alloc]init];
    guangxi_beiliu.HospitalCode = @"GXBLYY";
    guangxi_beiliu.HospitalName = @"广西北流医院";
    guangxi_beiliu.IPAddressOrDomainName = @"172.16.99.62";
    guangxi_beiliu.IISApplicationName = @"";
    guangxi_beiliu.Port = @"80";
    [self.theHospitalList addObject: guangxi_beiliu];

    AppServiceModel *xiamen_zhongshan = [[AppServiceModel alloc]init];
    xiamen_zhongshan.HospitalCode = @"XMZSYY";
    xiamen_zhongshan.HospitalName = @"厦门中山医院";
    xiamen_zhongshan.IPAddressOrDomainName = @"192.10.33.221";
    xiamen_zhongshan.IISApplicationName = @"";
    xiamen_zhongshan.Port = @"8090";
    [self.theHospitalList addObject: xiamen_zhongshan];
    

    
    return self;
}

-(AppServiceModel*) GetDefault{
    /*
     * bulid 号不能私自修改，改为版本号加横杠 比如 0.0.1.dev 代表使用dev配置
     
     NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
     NSString *bulid = [infoDictionary objectForKey:@"CFBundleVersion"];
     */
    
    NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
    NSString *appVersion = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
    
    NSString *bulid = @"dev";
    NSArray *arrVersion = [appVersion componentsSeparatedByString:@"."];
    if( arrVersion.count == 4){
        bulid = arrVersion[3];
    }
    
    for (AppServiceModel *model in self.theHospitalList) {
        if([model.HospitalCode  isEqual: bulid]){
            return model;
        }
    }
    
    return self.theHospitalList.firstObject;
}



@end
